<template>
	<view class="box">
		<uNavbar title="我的订单" ></uNavbar>
		
<!-- 		<view class="tab-nav">
			<view class="tab-list-item" v-for="item in toggleList" :key="item.id" @click="clickToggleHandle(item)">
				<view :class="{ active: item.select}" class="text">{{ item.label }}</view>
			</view>
		</view> -->
		<!--我接收的 -->
<!-- 		<view class="main_from">
			<view class="main_from_top" >
				<image src="../../static/image/bg6.png" mode="aspectFill"></image>
				<view class="main_from_top_one">
					<view class="name">
						华小福
					</view>
					<view class="main_from_top_one_text">
						已购买
					</view>
				</view>
				<view class="main_from_top_two">
					<view class="text">
						大唐盛世官方
					</view>
					<view class="num">
						×99
					</view>
				</view>
				<view class="main_from_top_three">
					<view class="price">
						<image src="../../static/icon/i_money.png" mode=""></image>
						￥799.00
					</view>
				</view>
		
			</view>
			<view class="main_from_bottom">
				<view class="main_from_bottom_text flex_ld" >
					查看详情
				</view>
				<view class="exchange" >
					<text @click="goAddress">兑换</text>
					<text  @click="confirmGoods">确认收货</text>
				</view>
			</view>
		</view> -->
		
		<view  style="margin-top: 20rpx;">
			<view class="main_from" v-for="item in  orderlist " :key="item.id"  @click="gopaid(item.id)">
				<view class="main_from_top" >
					<image :src="item.good.goods_image" mode="aspectFill"></image>
					<view class="main_from_top_one">
						<view class="name">
							{{item.good.goods_name}}
						</view>
						<view class="main_from_top_one_text">
							{{item.status_desc}}
						</view>
					</view>
					<view class="main_from_top_two">
						<view class="text">
							{{item.good.brand_name}}
						</view>
						<view class="num">
							×{{item.number}}
						</view>
					</view>
					<view class="main_from_top_three">
			<!-- 			<view class="tag_wrap"> 
							<view class="tag">
								编号
							</view>
							<view class="tag_num">
								200/1000
							</view>
						</view> -->
						<view class="price">
							<image v-if="item.pay_type==3 ||item.pay_type==6 " src="../../static/icon/i_money.png" mode=""></image>
							<image style="width: 36rpx;height: 24rpx;" v-if="item.pay_type==4" src="../../static/image/fhyb.png" mode=""></image>
							<image v-if="item.pay_type==5" src="../../static/icon/i_ful.png" mode=""></image>
							{{ item.pay_type==5? (item.price/item.ufl_rmb_prop).toFixed(6) :item.price}}
						</view>
					</view>
			
				</view>
				<view class="main_from_bottom">
					<view class="main_from_bottom_text flex_ld">
						查看详情
						<uni-icons style="margin-right: 20rpx;" type="right" color="#A6A5AF"></uni-icons>
					</view>
			
			<!-- 		<view class="btn_canel">
						转赠
					</view> -->
				
			<!-- 		<view class="btn" >
						挂卖
					</view> -->
				</view>
			</view>
		</view>
		<u-popup :show="tipShow" mode="center" @close="tipShow = false" closeable bgColor="transparent">
			<view class="prompt flex_ZC">
				<text class="f36">提示</text>
				<text class="prompt_tit">为了保障您的权益，请检查后确认收货</text>
				<view class="prompt_ntm" @click="isConfirm">
					<text>确认</text>
				</view>
				<view class="empty"></view>
			</view>
		</u-popup>
		<noDatas :xxxList="orderlist" :status="status"></noDatas>
		<view class="empty"></view>
	</view>

</template>

<script>
	import {orderList} from "../../api/order.js"
	export default {
		data() {
			return {
				tipShow:false,
				toggleList: [{
						label: '待支付',
						select: true
					},
					{
						label: '已购买',
						select: false
					}
				],
				aaaList: [null, null, null, null, null, null, null, null, null, null, ],
				selval: "待支付",
				orderlist:[],
				page: 1,
				size: 10,
				status: 'loadmore', //加载前值为loadmore，加载中为loading，没有数据为nomore
			}
		},
		onLoad() {
			this.getorderList()
		},
		methods: {
			getorderList(){
				orderList({
					page:this.page
				}).then(res=>{
					if (res.code == 1) {
						let list = res.data.data;
						this.orderlist = this.page == 1 ? list : this.orderlist.concat(list);
						console.log(this.orderlist);
						if (list.length < this.size) this.status = 'nomore';
						else this.status = 'loading';
					}
			
				})
			},
 			clickToggleHandle(ele) {
				this.toggleList.forEach(item => item.select = false)
				this.currLabel = ele.label
				ele.select = true
				console.log(ele)
				this.selval = ele.label
			},
			gounpaid() {
				uni.navigateTo({
					url: "/pagesMy/myorder/unpaid"
				})
			},
			goAddress(){
				uni.navigateTo({
					url:'/pagesMy/setting/receivingAddress'
				})
			}, 
			confirmGoods(){
				this.tipShow = true
			},
			isConfirm(){
				this.tipShow = false
				console.log('调取接口');
			},
			gopaid(id) {
				uni.navigateTo({
					url: `/pagesMy/myorder/paid?id=${id}`
				})
			}

		},
		onReachBottom() {
			if (this.status != 'nomore') {
				this.page = this.page + 1
				this.getorderList()
			}
		},
		onPullDownRefresh() {
			console.log('下拉刷新');
			let that = this;
			setTimeout(function() {
				that.page = 1,
				that.getorderList()
			}, 800);
		},
	}
</script>

<style lang="scss" scoped>
	.box {
		width: 750rpx;
		// height: 100vh;
		background-color:#E0DDDA;
		position: relative;
	}

	.tab-nav {
		width: 750rpx;
		height: 100rpx;
		background-color: #E0DDDA;
		display: flex;
		align-items: center;
		position: fixed;
		z-index: 999;
		.tab-list-item {
			position: relative;
			width: 350rpx;

			.text {
				display: flex;
				justify-content: center;
				align-items: center;
				margin-left: 50rpx;
				padding: 20rpx;
				height: 52rpx;
				opacity: 1;
				font-weight: 400;
				text-align: center;
				font-size: 32rpx;
				color: #A6A5AF;
			}

			.active {
				font-family: PingFang SC-Medium, PingFang SC;
				font-weight: 400;
				color: #FFFFFF;
			}
		}
	}

	.main_from {
		width: 690rpx;
		// height: 330rpx;
		background:#F2F2F2;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		margin: 0 auto;
		margin-top: 40rpx;

		.main_from_top {
			margin: 0 auto;
			width: 630rpx;
			height: 220rpx;
			border-bottom: 2rpx solid #CFC4B7;
			
			position: relative;

			>image {
				width: 154rpx;
				height: 154rpx;
				border-radius: 20rpx 20rpx 20rpx 20rpx;
				margin-top: 30rpx;
			}

			.main_from_top_one {
				width: 400rpx;
				position: absolute;
				top: 36rpx;
				left: 192rpx;
				display: flex;
				justify-content: space-between;
				align-items: center;

				.name {
					width: 240rpx;
					height: 52rpx;
					font-weight: 400;
					font-size: 32rpx;
					color: #333;
					white-space: nowrap;
					/* 不换行 */
					overflow: hidden;
					/* 超出部分隐藏 */
					text-overflow: ellipsis;
					/* 显示省略号 */
				}

				.time {
					line-height: 52rpx;
					height: 52rpx;
					font-size: 26rpx;
					color: #FF2CDF;
				}

				.main_from_top_one_text {
					font-size: 26rpx;
					color: #A68A64;
					line-height: 26rpx;
					// margin-left: 110rpx;
				}
			}

			.main_from_top_two {
				width: 400rpx;
				position: absolute;
				top: 86rpx;
				left: 192rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;

				.text {
					width: 280rpx;
					height: 52rpx;
					line-height: 52rpx;
					font-weight: 400;
					font-size: 24rpx;
					color: #A6A5AF;
					white-space: nowrap;
					/* 不换行 */
					overflow: hidden;
					/* 超出部分隐藏 */
					text-overflow: ellipsis;
					/* 显示省略号 */
				}

				.num {

					font-size: 30rpx;
					color: #A7A4AD;
				}
			}

			.main_from_top_three {
				width: 400rpx;
				position: absolute;
				top: 146rpx;
				left: 192rpx;
				display: flex;
				align-items: center;
				justify-content: flex-end;

				.tag_wrap {
					width: 300rpx;

					font-weight: 400;
					font-size: 24rpx;
					color: #A6A5AF;
					white-space: nowrap;
					/* 不换行 */
					overflow: hidden;
					/* 超出部分隐藏 */
					text-overflow: ellipsis;
					display: flex;

					/* 显示省略号 */
					.tag {
						width: 64rpx;
						height: 36rpx;
						background: linear-gradient(274deg, #0014FF 0%, #8020EF 50%, #FF2CDF 100%);
						border-radius: 6rpx 6rpx 6rpx 6rpx;
						font-size: 22rpx;
						color: #FFFFFF;
						text-align: center;
						line-height: 36rpx;
					}

					.tag_num {
						width: 150rpx;
						height: 36rpx;
						background: #2B2951;
						border-radius: 6rpx 6rpx 6rpx 6rpx;
						text-align: center;
						line-height: 36rpx;
						font-size: 24rpx;
						color: #FFFFFF;
					}
				}

				.price {
					display: flex;
					align-items: center;
					>image{
						width: 28rpx;
						height: 28rpx;
						margin-right: 6rpx;
					}
					font-size: 32rpx;
					color: #A68A64;
				}
			}


			.tip {
				position: absolute;
				top: 74rpx;
				right: 0rpx;
				font-size: 36rpx;
				color: #FF2CDF;
			}
		}

		.main_from_bottom {
			width: 630rpx;
			// height: 100rpx;
			margin: 0 auto;
			padding: 20rpx 0;
			display: flex;
			align-items: center;
			justify-content: space-between;

			.main_from_bottom_text {
				width: 100%;
				height: 52rpx;
				font-size: 26rpx;
				color: #A6A5AF;
				line-height: 52rpx;
			}

			.btn_canel {
				width: 152rpx;
				height: 52rpx;
				border-radius: 536rpx 536rpx 536rpx 536rpx;
				border: 2rpx solid #A6A5AF;
				font-weight: 400;
				font-size: 26rpx;
				color: #A6A5AF;
				line-height: 52rpx;
				text-align: center;
				margin-left: 226rpx;
			}

			.btn {
				width: 122rpx;
				height: 52rpx;
				border-radius: 536rpx 536rpx 536rpx 536rpx;
				border: 2rpx solid #FF2CDF;
				font-weight: 400;
				font-size: 26rpx;
				color: #FF2CDF;
				line-height: 52rpx;
				text-align: center;
			}
		}
	}
	.exchange{
		width: 100%;
		// background: pink;
		display: flex;
		align-items: center;
		justify-content: flex-end;
	}
	.exchange>text{
		padding: 10rpx 36rpx;
		text-align: center;
		border-radius: 36rpx;
		border: 2rpx solid #FF2CDF;
		font-size: 26rpx;
		color: #FF2CDF;
	}
	.prompt {
		width: 600rpx;
		min-height: 400rpx;
		background: #E0DDDA;
		margin: 0 auto;
		border-radius: 20rpx;
		color: #333;
		padding-top: 30rpx;
	}

	.prompt>text {
		margin-top: 40rpx;
	}

	.prompt_tit {
		margin: 0 30rpx;
		font-size: 28rpx;
		color: #333;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
		overflow: hidden;
	}

	.prompt_ntm {
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 30rpx;
		width: 414rpx;
		height: 72rpx;
		line-height: 72rpx;
		background: linear-gradient( 90deg, #AB8E68 0%, #D7BA93 100%);
		border-radius: 28rpx;
		margin-top: 80rpx;
		color: #ffffff;
	}
</style>